package com.coscon.utils;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 工具类
 * @author 409390047@qq.com
 * @Date: 2021/6/16 10:13
 */
public class IpAddressUtils {
    public static String getLocalHostName(){
        InetAddress addr = null;
        try {
            addr = InetAddress.getLocalHost();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        String ip = "";
        String hostName = "";
        if(addr!=null){
            //获取本机ip
            ip=addr.getHostAddress();
            //获取本机计算机名称
            hostName=addr.getHostName();
        }
        return ip+"/"+hostName;
    }
}
